/** 子路由，负责子模块的视图跳转，最后汇总到app.routes中。 */
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { HomeComponent } from './home.component';
import { HomeListComponent } from './home-list.component';
import { HomeCenterComponent } from './home-center.component';
import { HomeDetailComponent } from './home-detail.component';

import { CanDeactivateGuard } from '../../shared/can-deactivate-guard.service';

import { HomeDetailResolve } from './home-detail-resolve.service';

export const routes: Routes = [
  {
    path: '',
    component: HomeComponent,
    children: [
      {
        path: '',
        component: HomeListComponent,
        children: [
          {
            path: ':id',
            component: HomeDetailComponent,
            canDeactivate: [CanDeactivateGuard],
            resolve: {
              home: HomeDetailResolve
            }
          },
          {
            path: '',
            component: HomeCenterComponent
          }
        ]
      }
    ]
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
  providers: [
    HomeDetailResolve
  ]
})
export class HomeRoutingModule { }
